home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Finger Server Source / sip_glue.h < prev    next >
Text File  |  1993-08-12  |  3KB  |  145 lines

  1. /*
  2.  * tcp/ip io glue
  3.  */
  4.  
  5. #pragma once
  6.  
  7. #include "MacTCPCommonTypes.h"
  8. #include "TCPPB.h"
  9. #include <Processes.h>
  10.  
  11. #define TCP_FINGER_PORT (79)
  12.     
  13. /*
  14.  * an asyncronous io request
  15.  */
  16. struct side_R {
  17.     TCPiopb     ipb;                /*io parameters for current io */
  18.     struct tcp_conv_R *sconv;        /*conversation block for this io*/
  19.     wdsEntry       awds[2];
  20. };
  21. typedef struct side_R tcp_side, *side_pt;
  22.  
  23. #define MACTCP_RECV_BUFFER_LEN     (4500)
  24. #define MACTCP_SEND_BUFFER_LEN    (6500)
  25. #define    SEND_TIMEOUT            (90)    //seconds to time out a send
  26. #define MAX_NUM_CONVS             (3)
  27.  
  28. #define ST_FREE        (0)
  29. #define ST_LISTEN    (1)
  30. #define ST_SEND        (2)
  31. #define ST_CLOSE    (3)
  32.  
  33. /*
  34.  * set to false to quit server
  35.  */
  36. extern int sip_keep_running;
  37.  
  38. #define TCP_WAKE_MAGIC_NUM ('AdG3')
  39.  
  40. /*
  41.  * info used at interupt time to wake a process
  42.  */
  43. struct process_wakeup_control_R {
  44.     int             need_wake_up;
  45.     int             can_sleep;
  46.     ProcessSerialNumber    server;
  47.     Ptr                a5;
  48.     long            tcp_wake_magic_num;
  49. };
  50. typedef struct process_wakeup_control_R process_wakeup_control,*process_wakeup_control_pt;
  51.  
  52. /*
  53.  * one connection
  54.  */
  55. struct tcp_conv_R {
  56.     int            state;
  57.     int            service_me;
  58.     process_wakeup_control_pt server_proc;
  59.     char        mactcp_recv_buffer[MACTCP_RECV_BUFFER_LEN];
  60.     char        mactcp_send_buffer[MACTCP_SEND_BUFFER_LEN];
  61.     int            closing;
  62.     int            terminating;
  63.     int            data_arrived;
  64.     StreamPtr    tcpStream;
  65.     tcp_side    write_side;
  66.     int            last_event;
  67. };
  68. typedef struct tcp_conv_R tcp_conv, *tcp_conv_pt;
  69.  
  70. /*
  71.  * handle action on each tcp connection
  72.  */
  73. void tcp_service_event(void);
  74.  
  75. /*
  76.  * clean up all the streams
  77.  */
  78. void tcp_release_streams(void);
  79.  
  80. /*
  81.  * setup all the streams
  82.  */
  83. int tcp_init_streams(void);
  84.  
  85. /*
  86.  * release a tcp stream, aborting any io in progress
  87.  */
  88. void tcp_release_connection(tcp_conv_pt sconv);
  89.  
  90. /*
  91.  * open the mactcp device driver
  92.  * returns true on an error
  93.  */
  94. int tcp_open_driver(void);
  95.  
  96. /*
  97.  * did any new events happens since we last awoke?
  98.  */
  99. int tcp_ok_to_sleep_now(void);
  100.  
  101. /*
  102.  * create a tcp stream
  103.  */
  104. int tcp_create_stream(tcp_conv_pt uptr);
  105.  
  106. /*
  107.  * close a tcp stream
  108.  */
  109. int tcp_close(tcp_conv_pt uptr);
  110.  
  111. /*
  112.  * just woke up and will service any requests
  113.  */
  114. void tcp_just_awoke(void);
  115.  
  116. /*
  117.  * transfer outgoing packets into MacTCP output buffer
  118.  */
  119. int tcp_send_packet(tcp_conv_pt sconv);
  120.  
  121. /*
  122.  * recieve data on this connection
  123.  * the data is left in an internal mactcp buffer which must be returned to mactcp
  124.  * with the returnTCPbuffer proceedure
  125.  */
  126. int tcp_recv_packet(tcp_conv_pt sconv);
  127.  
  128. /*
  129.  * passive connection to listen for incomming tcp connections
  130.  */
  131. int tcp_passive_connect(tcp_conv_pt sconv,tcp_port port_number);
  132.  
  133. /*
  134.  * allocate io buffers
  135.  * return true on error
  136.  */
  137. int tcp_allocate_memory(void);
  138.  
  139. /*
  140.  * setup one stream
  141.  */
  142. int tcp_init_stream(tcp_conv_pt sconv);
  143.  
  144.  
  145.